<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录</title>
	<!-- 小标图 -->
    <link rel="Shorcut Icon" href="${request.contextPath}${staticPath}/images/ico.png" type="image/x-icon" />
    <link rel="stylesheet" href="${request.contextPath}${staticPath}/css/login.css">
    <link rel="stylesheet" href="${request.contextPath}${staticPath}/css/base.css">
    <script type="text/javascript" src="${request.contextPath}${staticPath}/admin/plugins/jquery/jquery-3.4.1.js"></script>
  	<script src="${request.contextPath}${staticPath}/admin/plugins/layer/layer.js"></script>
</head>
<body>
	<#include "${request.contextPath}/base/header.html">
    <div class="login_conent">
        <div class="login">
            <h1 class="loh1" >用户登录</h1>
            <div class="reg_info f15">
                <div class="reg_left">
                    <p class="regp">&nbsp;→&nbsp;&nbsp;请输入您的账号信息，用于登录天地华宇系统</p>
                    <hr class="reghr" />
                    <form action="javascript:void(0)" method="post">
                    <div class="logindiv">
                        <div class="name loginnp">
                            <label for="">用户名：</label>
                            <input type="text" id="userName" name="userName" placeholder="请输入邮箱或手机号">
                        </div>
                        <div class="pwd loginnp">
                                <label for="">密&nbsp;&nbsp;码：</label>
                                <input type="password" id="userPassword" name="userPassword" placeholder="请输入密码">
                            </div>
                        <div class="reg_bar">
                            <a href="#" class="rega">忘记密码</a>
                            <br />
                            <button  class="regb" onclick="admin_submit()">登录</button>
                            <a class="regb" href="/tdhy/toRegister">注册</a>
                        </div>
                    </div>
                    </form>
                </div>
                <div class="reg_right">
                    <p class="regrp">还没有账号，<a href="/tdhy/toRegister">立即去注册  >></a></p>
                    <p>注册成为<b>天地华宇会员</b>，您可以享受更多的服务</p>
                    <br />
                    <div class="regul">
                        <ul>
                            <li class="regrli">账号一体化</li>
                            <li class="regrli">快捷下单</li>
                            <li class="regrli">在线理赔</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <#include "${request.contextPath}/base/foot.html">
</body>
<script type="text/javascript">
	function admin_submit(){
		if ($("#userName").val()==""){
			layer.msg("请输入邮箱或手机号")
			return false;
		}else if ($("#userPassword").val()==""){
			layer.msg("请输入密码")
			return false;
		}else{
			data={
					"userName":$("#userName").val(),
					"userPassword":$("#userPassword").val()
			}
			console.log(data.userName);
			$.ajax({
				"url":"${request.contextPath}/tdhy/login",
				"contentType":"application/json",
				"data":JSON.stringify(data),
				"type":"post",
				"dataType":"json",
				"success":function (resultMsg){
					console.log(resultMsg);
					if(resultMsg==1){
						window.location.href="${request.contextPath}/admin/index";
					}else {
						layer.msg("密码或用户名错误，请重新输入");
					}
				}
			});
		}
	}
	function admin_register(){
		//window.location.href="${request.contextPath}/register";
	}
</script>
</html>